<template>
  <div class="user-center-container">
    <header>
      <h1>个人中心</h1>
    </header>
    <main>
      <div class="user-info">
        <div class="avatar">
          <img src="../assets/logo.png" alt="用户头像">
        </div>
        <div class="info">
          <h2>用户名: 测试用户</h2>
          <p>ID: 10001</p>
          <p>注册时间: 2023-07-01</p>
        </div>
      </div>
      <div class="settings">
        <h3>账户设置</h3>
        <ul>
          <li @click="goToChatHistory">聊天历史</li>
          <li @click="logout">退出登录</li>
        </ul>
      </div>
    </main>
  </div>
</template>

<script>
import { useRouter } from 'vue-router'

export default {
  name: 'UserCenter',
  setup() {
    const router = useRouter()

    const goToChatHistory = () => {
      router.push('/chat-history')
    }

    const logout = () => {
      // 清除登录状态
      localStorage.removeItem('isLoggedIn')
      // 跳转到登录页
      router.push('/login')
    }

    return {
      goToChatHistory,
      logout
    }
  }
}
</script>

<style scoped>
.user-center-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  padding: 10px 20px;
  background-color: #42b983;
  color: white;
  text-align: center;
}

main {
  flex: 1;
  padding: 20px;
  background-color: #f9f9f9;
}

.user-info {
  display: flex;
  padding: 20px;
  margin-bottom: 20px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

.avatar {
  margin-right: 20px;
}

.avatar img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
}

.info h2 {
  margin-bottom: 10px;
  color: #333;
}

.info p {
  margin-bottom: 5px;
  color: #666;
}

.settings {
  padding: 20px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

.settings h3 {
  margin-bottom: 15px;
  color: #333;
}

.settings ul {
  list-style: none;
  padding: 0;
}

.settings li {
  padding: 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background-color 0.3s;
}

.settings li:hover {
  background-color: #f0f0f0;
}
</style>